package com.qf.student.service.impl;

import com.qf.student.dao.IStudentDao;
import com.qf.student.dao.impl.StudentDaoImpl;
import com.qf.student.entity.Student;
import com.qf.student.service.IStudentService;

import java.util.List;

/**
 * @version1.0
 * @auth dmh
 */
public class StudentServiceImpl implements IStudentService {
    private IStudentDao studentDao=new StudentDaoImpl();


    @Override
    public boolean save(Student student) {
        //判断这个学生是否存在(根据学生的id查询一次,查询到了就存在,查询不到就不存在)

        //调用dao层入库
        int insert = studentDao.insert(student);
        //入库是否成功,返回结果给上级
        return insert > 0;
    }

    @Override
    public boolean update(Student student) {
        return studentDao.updateById(student)>0;
    }

    @Override
    public boolean remove(Integer id) {
        return studentDao.deleteById(id)>0;
    }

    @Override
    public Student getById(Integer id) {
        return studentDao.selectById(id);
    }

    @Override
    public List<Student> list() {
        return studentDao.selectList();
    }

    @Override
    public Student getByName(String name) {
        return studentDao.selectByName(name);
    }

}
